public class SmallDui {
    int[] elem = new int[10];
    int usesize;

    public SmallDui() {
       elem = new int[10];
    }
    public void intimit(int[] arrray){
        for (int i = 0; i < arrray.length; i++) {
            elem[i] = arrray[i];
            usesize++;
        }
    }
    public void creatTree(){
        for (int parent = (usesize-1-1)/2; parent >=0; parent--) {
            sift(parent,usesize);
        }
    }

    private void sift(int parent, int usesize) {
        int child = parent*2+1;
        while(child<usesize){
            if(child<usesize-1 && elem[child]<elem[child+1]){
                child=child+1;
            }
            if(elem[child]>elem[parent]){
                int tem = elem[child];
                elem[child] = elem[parent];
                elem[parent] = tem;
                parent = child;
              child = 2*parent + 1;
            }
            else {
                break;
            }
        }
    }

}
